﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using DataAccessLibrary;
using DataAccessLibrary.DAL;
using context;
using entities;

namespace BusinessLogicLibrary.BookingModule
{
    public class BookingManagement
    {
        private BookingDAO bookingDAO = new BookingDAO();

        public string CreateBooking(string pCustomerID, List<int> pRoomID,DateTime pCheckInDate, DateTime pCheckOutDate)
        {
            pCheckInDate = pCheckInDate.Add(new TimeSpan(13, 0, 0));
            pCheckOutDate = pCheckOutDate.Add(new TimeSpan(12, 0, 0));
            // Booking
            var booking = new Booking
            {
                CustomerID = pCustomerID,
                BookingDate= DateTime.Today
            };
            
            //CheckIn
            List<CheckIn> lstCheckIn = new List<CheckIn>();
            foreach (int rID in pRoomID)
            {
                var checkin = new CheckIn
                {
                    RoomID = rID,
                    CheckInDate = pCheckInDate,
                    CheckOutDate = pCheckOutDate,
                    Available = false
                };
                lstCheckIn.Add(checkin);   
            }            
                     
            return bookingDAO.InsertBooking(booking, lstCheckIn);
        }
    }
}
